#include "PLTriangle.h"

#include "PLEdge.h"

using std::vector;

PLuint PLTriangle::numTriangles = 0;

/**
  *	Constructs a new PLTriangle object by copying the pointers in the given
  * edgeVector. The PLEdge objects themselves are not copied!
  *
  * @param edgeVector vector of pointers to the three PLEdge objects
  */
PLTriangle::PLTriangle( const std::vector<PLEdge*> &edgeVector )
{
	mEdges.assign( edgeVector.begin(), edgeVector.end() );
	numTriangles++;
}

/**
  *	Destroys the PLTriangle object and all the PLEdge objects
  */
PLTriangle::~PLTriangle()
{
	for (vector<PLEdge*>::iterator it = mEdges.begin();
		it != mEdges.end(); it++)
	{
		delete *it;
	}

	numTriangles--;
}

/**
  *	Returns a const reference to the vector with the pointers to the three
  * PLEdge objects
  *
  * @return const reference to the vector with the pointers to the three PLEdge objects
  */
const std::vector<PLEdge*> &PLTriangle::GetEdges( void ) const
{
	return mEdges;
}

/**
  *	Returns the currently instantiated number of PLTriangle objects
  *
  * @return currently instantiated number of PLTriangle objects
  */
const PLuint &PLTriangle::GetNumTriangles( void )
{
	return numTriangles;
}